package com.tj.bo.account.server.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.tj.bo.account.server.dao.OrderWithdrawDao;
import com.tj.bo.account.server.entity.OrderWithdrawEntity;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: account
 * Date: 2020-06-11
 * Time: 10:48:23.894
 */

@Repository
public class OrderWithdrawDaoImpl extends AbstractBaseMapper<OrderWithdrawEntity> implements OrderWithdrawDao {
    @Override
    public OrderWithdrawEntity selectByWithdrawOrderNo(String withdrawOrderNo) {
        Map<String, Object> params = new HashMap<>();
        params.put("withdrawOrderNo", withdrawOrderNo);
        return getSqlSession().selectOne(getStatement("selectByWithdrawOrderNo"), params);
    }

    @Override
    public List<OrderWithdrawEntity> selectListByStatus(Integer status) {
        Map<String, Object> params = new HashMap<>();
        params.put("status", status);
        return getSqlSession().selectList(getStatement("selectListByStatus"), params);
    }

    @Override
    public OrderWithdrawEntity selectLatestOrder(String userCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCode", userCode);
        return getSqlSession().selectOne(getStatement("selectLatestOrder"), params);
    }

    @Override
    public List<OrderWithdrawEntity> selectLatestOrders(String userCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCode", userCode);
        return getSqlSession().selectList(getStatement("selectLatestOrders"), params);
    }

    @Override
    public BigDecimal selectTotalWithdrawAmount(String userCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCode", userCode);
        return getSqlSession().selectOne(getStatement("selectTotalWithdrawAmount"), params);
    }
}